#ifndef PROFILEMANAGER_H
#define PROFILEMANAGER_H

#include <QObject>
#include <QMap>
#include <QCache>
#include <QPixmap>
#include <QNetworkAccessManager>

namespace ImageDownload {

class ProfileManager : public QObject
{
    Q_OBJECT
public:
    static ProfileManager* instance(QObject *parent = 0);

    void imageGet( const QString& imageUrl );
    bool contains( const QString &imageUrl ) const;
    QPixmap* imageFromUrl( const QString &imageUrl ) const;

protected:
    ProfileManager( QObject *parent = 0 );
    ~ProfileManager();

signals:
    void imageReadyForUrl(const QString &path, QPixmap *image);

Q_SIGNALS:
    // The change notification signals of the properties
    void imageReady();
    void imageChanged();
    void labelChanged();
    void loadingChanged();

private slots:
    void requestFinished(QNetworkReply *reply);

private:
    QMap<QString, QNetworkAccessManager*> m_connections;
    QCache<QString, QPixmap> m_imageCache;
    static ProfileManager *m_instance;
    
};

}
#endif // PROFILEMANAGER_H
